<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div th:insert="common.html"></div>
<div class="container-fluid" align="center">
  <div class="panel panel-primary" style="width:400px">
    <div class="panel-heading">
      <h1>登录</h1>
    </div>
    <div class="panel-body">
      <form id="form_id">
        <div class="form-group">
          <label for="pname">账号</label>
          <input type="text" class="form-control" name="pname" id="pname"
                 placeholder="请输入账号">
          <div id="tips"></div>
        </div>
        <div class="form-group">
          <label for="pwd">密码</label>
          <input type="password" class="form-control" name="pwd" id="pwd">
        </div>
        <div class="form-group">
          <label for="vcode">验证码</label>
          <input type="text" class="form-control" name="vcode" id="vcode"
                 placeholder="请输入验证码">
          <img  id="imgvcode" src="/code/vcode" onclick="co(this)">
        </div>
        <input type="button" class="btn btn-success btn-lg" value="登录" onclick="login()">
      </form>
    </div>
  </div>
</div>
</body>
</html>
    <script type="text/javascript">
        function login(){
          $.ajax({
            url : "/person/login",
            type : "get",
            dataType : "json",
            data : $("#form_id").serialize(),
            success : function (data){
              if (data.flag){
                toastr.success("登录成功");
                location.href="/routeController/test";
              }else{
                toastr.error(data.msg)
              }

            },
            error : function (data){
              toastr.success("网络连接失败")
            }
          })
      }

      function co(o){
        o.src="/code/vcode?time=" + new Date().getTime();
      }
</script>